# output directory config
ifeq ($(O),)
_OUTDIR = $(EELDIR)/output
else
_OUTDIR = $(O)
endif

# eel top dir
EEL_DL_DIR				= $(EELDIR)/download
EEL_CHG_DIR				= $(EELDIR)/changes
EEL_SRC_DIR				= $(EELDIR)/source
EEL_DEMO_DIR			= $(EELDIR)/democodes
EEL_TC_DIR				= $(EELDIR)/toolchain
EEL_OUT_DIR				= $(shell mkdir -p $(_OUTDIR) && cd $(_OUTDIR) && pwd -P)
export EEL_DL_DIR EEL_CHG_DIR EEL_SRC_DIR EEL_TC_DIR EEL_OUT_DIR

TMP_DIR					?= /tmp

# QEMU share dir
# mount -t 9p mnt_comm /mnt/
SHARE_DIR_COMM			= $(EELDIR)/share
# mount -t 9p mnt_arch /mnt/arch, use the top directory to store symbol links
SHARE_DIR_ARCH			= $(EEL_OUT_DIR)/$(ARCH)

# build config, BUILD_DEPS can not use :=
BUILD_DEPS				= $(TC_PATH)
JOB_OPT 				?= -j$(shell nproc)

# Permission
ifeq ($(SUDO_USER),)
USERNAME				?= $(shell whoami)
else
USERNAME				?= $(SUDO_USER)
endif

# echo $PASSWD | sudo -S
SUDO 					?= sudo
FAKEROOT 				?= fakeroot

# rsync options
RSYNC_OPTS				+= -P
RSYNC_OPTS				+= -r
RSYNC_OPTS				+= -ogp
RSYNC_OPTS				+= -t
# RSYNC_OPTS				+= -z
# RSYNC_OPTS				+= -u
RSYNC_OPTS				+= $(RSYNC_OPTS_EXCLUDE)

RSYNC_OPTS_EXCLUDE		+= --exclude .svn --exclude .git
RSYNC_OPTS_EXCLUDE		+= --exclude .diff --exclude .patch
RSYNC_OPTS_EXCLUDE		+= --exclude .rej --exclude .orig
# ctags files
RSYNC_OPTS_EXCLUDE		+= --exclude tags --exclude TAGS
# cscope files
RSYNC_OPTS_EXCLUDE		+= --exclude cscope.* --exclude ncscope.*
# gnu global files
RSYNC_OPTS_EXCLUDE		+= --exclude GPATH --exclude GRTAGS --exclude GSYMS --exclude GTAGS

RSYNC_OPTS_EXCLUDE		+= --exclude *.a
RSYNC_OPTS_EXCLUDE		+= --exclude *.asn1.[ch]
RSYNC_OPTS_EXCLUDE		+= --exclude *.bin
RSYNC_OPTS_EXCLUDE		+= --exclude *.bz2
RSYNC_OPTS_EXCLUDE		+= --exclude *.c.[012]*.*
RSYNC_OPTS_EXCLUDE		+= --exclude *.dt.yaml
RSYNC_OPTS_EXCLUDE		+= --exclude *.dtb
RSYNC_OPTS_EXCLUDE		+= --exclude *.dtbo
RSYNC_OPTS_EXCLUDE		+= --exclude *.dtb.S
RSYNC_OPTS_EXCLUDE		+= --exclude *.dtbo.S
RSYNC_OPTS_EXCLUDE		+= --exclude *.dwo
RSYNC_OPTS_EXCLUDE		+= --exclude *.elf
RSYNC_OPTS_EXCLUDE		+= --exclude *.gcno
# RSYNC_OPTS_EXCLUDE		+= --exclude *.gz
RSYNC_OPTS_EXCLUDE		+= --exclude *.i
RSYNC_OPTS_EXCLUDE		+= --exclude *.ko
RSYNC_OPTS_EXCLUDE		+= --exclude *.lex.c
RSYNC_OPTS_EXCLUDE		+= --exclude *.ll
RSYNC_OPTS_EXCLUDE		+= --exclude *.lst
# RSYNC_OPTS_EXCLUDE		+= --exclude *.lz4
# RSYNC_OPTS_EXCLUDE		+= --exclude *.lzma
# RSYNC_OPTS_EXCLUDE		+= --exclude *.lzo
RSYNC_OPTS_EXCLUDE		+= --exclude *.mod
RSYNC_OPTS_EXCLUDE		+= --exclude *.mod.c
RSYNC_OPTS_EXCLUDE		+= --exclude *.o
RSYNC_OPTS_EXCLUDE		+= --exclude *.o.*
RSYNC_OPTS_EXCLUDE		+= --exclude *.patch
RSYNC_OPTS_EXCLUDE		+= --exclude *.rmeta
RSYNC_OPTS_EXCLUDE		+= --exclude *.rpm
RSYNC_OPTS_EXCLUDE		+= --exclude *.rsi
RSYNC_OPTS_EXCLUDE		+= --exclude *.s
RSYNC_OPTS_EXCLUDE		+= --exclude *.so
RSYNC_OPTS_EXCLUDE		+= --exclude *.so.dbg
RSYNC_OPTS_EXCLUDE		+= --exclude *.su
RSYNC_OPTS_EXCLUDE		+= --exclude *.symtypes
RSYNC_OPTS_EXCLUDE		+= --exclude *.symversions
RSYNC_OPTS_EXCLUDE		+= --exclude *.tab.[ch]
RSYNC_OPTS_EXCLUDE		+= --exclude *.tar
# RSYNC_OPTS_EXCLUDE		+= --exclude *.xz
# RSYNC_OPTS_EXCLUDE		+= --exclude *.zst
RSYNC_OPTS_EXCLUDE		+= --exclude Module.symvers
RSYNC_OPTS_EXCLUDE		+= --exclude modules.order

